package wjx.database.view;

import java.awt.EventQueue;
import java.awt.Font;

import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class CodingFrm extends JFrame {

	private JPanel contentPane;
	private JLabel label1, label2;
	private Box box1, box2, box;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CodingFrm frame = new CodingFrm();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public CodingFrm() {
		setVisible(true);
		setTitle("加密-解密线程状态监控");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 300, 100);
		setResizable(false);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		label1 = new JLabel("===线程开始工作===");
		label1.setFont(new Font("Lucida Grande", 1, 15));
		box = Box.createHorizontalBox();
		box.add(Box.createVerticalStrut(20));
		box.add(label1);
		contentPane.add(box);
	}

	public void fresh() {
//		System.out.println("freshing");
		String pr;
		box.remove(label1);
		contentPane.remove(box);
		contentPane.validate();
		if (MainFrm.myt.STATE == 0) {
			pr = "===空闲中===";
			label1 = new JLabel(pr);
			label1.setFont(new Font("Lucida Grande", 1, 15));
			System.out.println(pr);
		} else if (MainFrm.myt.STATE == 1) {			
			pr = "===加密中===";
			label1 = new JLabel(pr);
			label1.setFont(new Font("Lucida Grande", 1, 15));
			System.out.println(pr);
		} else {
			pr = "===解密中===";
			label1 = new JLabel(pr);
			label1.setFont(new Font("Lucida Grande", 1, 15));
			System.out.println(pr);
		}
		box.add(label1);
		contentPane.add(box);
		contentPane.updateUI();
	}

}
